<?php
header('content-type:text/html;charset=UTF-8');
require'model/Db.php';
$db = Db::getInstance();   //获取Db类实例

//更新
// $sql = "UPDATE student SET grade=99 WHERE id=1";
// $db->exec($sql);
// echo'成功更新了'.$db->num.'条记录';

//新增
// $sql = "INSERT student SET name='样',email='123@163.com',course='css',grade=99";
// $db->exec($sql);
// echo'成功新增了'.$db->num.'条记录,主键id是'.$db->insertId;

//删除
// $sql = "DELETE FROM student WHERE id=3";
// $db->exec($sql);
// echo'成功删除了'.$db->num.'条记录';

//查询单条
// $sql = "SELECT id,name,email,grade FROM student WHERE grade>60";
// $row = $db->fetch($sql);
// print_r($row);

//多条记录查询
$sql = "SELECT id,name,email,grade FROM student WHERE grade>0";
$rows = $db->fetchAll($sql);
echo "<pre>";
print_r($rows);